package com.roocon.thread.ExceptionHandler;

public class UncaughtExceptionHandlerExample {
    public static void main(String[] args) {
        Thread threadRun = new Thread(() -> {
            // 故意抛出一个运行时异常
            throw new RuntimeException("Intentional Exception");
        });

        threadRun.setUncaughtExceptionHandler((threadError, e) -> {
            System.out.println("Exception caught in thread: " + threadError.getName());
            System.out.println("Exception message: " + e.getMessage());
        });

        threadRun.start();
    }
}
